/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package twbb.utility;


import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import edu.cuny.cat.event.AuctionEvent;

import edu.cuny.util.Parameter;
import edu.cuny.util.ParameterDatabase;
import edu.cuny.util.io.CSVWriter;

/**
 *
 * @author sun
**/

public class ReportTWBBScore {

	static Logger logger = Logger.getLogger(ReportTWBBScore.class);

	protected CSVWriter log = null;

	protected int gameNum;

	public ReportTWBBScore() {
	}

	public ReportTWBBScore(CSVWriter log) {
		this.log = log;
	}

	public void setup(ParameterDatabase parameters, Parameter base) {

		log = new CSVWriter();
		log.setAutowrap(false);
		log.setAppend(false);
		log.setup(parameters, base);
	}

	public void generateHeader() {

		String headers[] = {  "game", "day", "marketshare", "profit", "transactionRate", "total" };

		for (int i = 0; i < headers.length; i++) {
			log.newData(headers[i]);
		}


		log.endRecord();
		log.flush();
	}

	public void updateLog(AuctionEvent event) {

		log.newData(gameNum);
		log.newData(event.getDay());		

		log.endRecord();
		log.flush();
	}

    public void close(){
        log.close();
    }

}


